import QtQuick 2.0
import QtQuick.Controls 2.5

Item {
    width: 850
    height: 580

    signal qmlSN_sqlWriteFinish()
    signal qmlSN_switchAnalog()
    onQmlSN_sqlWriteFinish: {
        if(!focus && $sqlMcRecorder.qml_getRefurbishFlag()) return
        if($sqlMcRecorder.qml_getPrintFlag()) console.log("->page6 operater start")
        //1-A通道
        for(var i=0; i<=11; i++)
            if($sqlMcRecorder.qml_getBitBool("A套","调节器状态",page_6IOMS_A.p6s_gridLayout.children[i].text)===true)
                page_6IOMS_A.p6s_gridLayout.children[i].checked = true;
            else page_6IOMS_A.p6s_gridLayout.children[i].checked = false;
        for(i=14; i<=21; i++)
            if($sqlMcRecorder.qml_getBitBool("A套","调节器状态",page_6IOMS_A.p6s_gridLayout.children[i].text)===true)
                page_6IOMS_A.p6s_gridLayout.children[i].checked = true;
            else page_6IOMS_A.p6s_gridLayout.children[i].checked = false;
        if($sqlMcRecorder.qml_getBitBool("A套","调节器状态","R631")===true)
            page_6IOMS_A.p6s_gridLayout.children[12].checked = true;
        else page_6IOMS_A.p6s_gridLayout.children[12].checked = false;
        if($sqlMcRecorder.qml_getBitBool("A套","调节器状态","R632")===true)
            page_6IOMS_A.p6s_gridLayout.children[13].checked = true;
        else page_6IOMS_A.p6s_gridLayout.children[13].checked = false;

        //2-B通道
        for(i=0; i<=11; i++)
            if($sqlMcRecorder.qml_getBitBool("B套","调节器状态",page_6IOMS_B.p6s_gridLayout.children[i].text)===true)
                page_6IOMS_B.p6s_gridLayout.children[i].checked = true;
            else page_6IOMS_B.p6s_gridLayout.children[i].checked = false;
        for(i=14; i<=21; i++)
            if($sqlMcRecorder.qml_getBitBool("B套","调节器状态",page_6IOMS_B.p6s_gridLayout.children[i].text)===true)
                page_6IOMS_B.p6s_gridLayout.children[i].checked = true;
            else page_6IOMS_B.p6s_gridLayout.children[i].checked = false;
        if($sqlMcRecorder.qml_getBitBool("B套","调节器状态","R631")===true)
            page_6IOMS_B.p6s_gridLayout.children[12].checked = true;
        else page_6IOMS_B.p6s_gridLayout.children[12].checked = false;
        if($sqlMcRecorder.qml_getBitBool("B套","调节器状态","R632")===true)
            page_6IOMS_B.p6s_gridLayout.children[13].checked = true;
        else page_6IOMS_B.p6s_gridLayout.children[13].checked = false;

        //3-系统（功率柜）
        for(i=1; i<5; i++){
            if($sqlMcRecorder.qml_getBitBool(Number(i)+"#","功率柜状态","功率柜退出")===true)
                page_5LimiterStatu_S.p6s_gridLayout.children[4*(i-1)].checked = true;
            else
                page_5LimiterStatu_S.p6s_gridLayout.children[4*(i-1)].checked = false;
            if($sqlMcRecorder.qml_getBitBool(Number(i)+"#","功率柜状态","功率柜均流投入")===true)
                page_5LimiterStatu_S.p6s_gridLayout.children[4*(i-1)+1].checked = true;
            else
                page_5LimiterStatu_S.p6s_gridLayout.children[4*(i-1)+1].checked = false;
            if($sqlMcRecorder.qml_getBitBool(Number(i)+"#","功率柜状态","功率柜A风机状态")===true)
                page_5LimiterStatu_S.p6s_gridLayout.children[4*(i-1)+2].checked = true;
            else
                page_5LimiterStatu_S.p6s_gridLayout.children[4*(i-1)+2].checked = false;
            if($sqlMcRecorder.qml_getBitBool(Number(i)+"#","功率柜状态","功率柜B风机状态")===true)
                page_5LimiterStatu_S.p6s_gridLayout.children[4*(i-1)+3].checked = true;
            else
                page_5LimiterStatu_S.p6s_gridLayout.children[4*(i-1)+3].checked = false;
        }
        if($sqlMcRecorder.qml_getPrintFlag()) console.log("->page6 operater stop")
    }

    SwipeView{
        id:swipeView_this
        orientation: Qt.Horizontal
        clip: true
        currentIndex: 0
        width: parent.width
        height: parent.height*0.85

        Item {
            id: firstPage
            Page_06IOMonitor_SingleChannle {
                id: page_6IOMS_A
                width: swipeView_this.width
                height: swipeView_this.height
                anchors.left: parent.left
                anchors.leftMargin: 50*main_screen.minSize
                p6s_gridLayout.rows: 8
                p6s_gridLayout.columns: 3
                p6s_gridLayout.columnSpacing: 20
                checkBoxNum: 22
                Component.onCompleted: {
                    p6s_gridLayout.children[0].text="零起升压"
                    p6s_gridLayout.children[1].text="残压起励"
                    p6s_gridLayout.children[2].text="本通道运行"
                    p6s_gridLayout.children[3].text="通道跟踪"
                    p6s_gridLayout.children[4].text="自动方式"
                    p6s_gridLayout.children[5].text="手动方式"
                    p6s_gridLayout.children[6].text="正常模式"
                    p6s_gridLayout.children[7].text="恒控制角模式"
                    p6s_gridLayout.children[8].text="灭磁开关分"
                    p6s_gridLayout.children[9].text="灭磁开关合"
                    p6s_gridLayout.children[10].text="逆变"
                    p6s_gridLayout.children[11].text="并网运行"
                    p6s_gridLayout.children[12].text="Ug>=10%"
                    p6s_gridLayout.children[13].text="Ug>=40%"
                    p6s_gridLayout.children[14].text="励磁回空到位"
                    p6s_gridLayout.children[15].text="系统电压跟踪"
                    p6s_gridLayout.children[16].text="恒Q控制"
                    p6s_gridLayout.children[17].text="恒PF控制"
                    p6s_gridLayout.children[18].text="短路干燥模式"
                    p6s_gridLayout.children[19].text="PSS有输出"
                    p6s_gridLayout.children[20].text="PSS投入"
                    p6s_gridLayout.children[21].text="PSS闭锁"
                }
            }
        }
        Item {
            id: secondPage
            Page_06IOMonitor_SingleChannle {
                id: page_6IOMS_B
                width: swipeView_this.width
                height: swipeView_this.height
                anchors.left: parent.left
                anchors.leftMargin: 50*main_screen.minSize
                p6s_gridLayout.rows: 8
                p6s_gridLayout.columns: 3
                checkBoxNum: 22
                Component.onCompleted: {
                    p6s_gridLayout.children[0].text="零起升压"
                    p6s_gridLayout.children[1].text="残压起励"
                    p6s_gridLayout.children[2].text="本通道运行"
                    p6s_gridLayout.children[3].text="通道跟踪"
                    p6s_gridLayout.children[4].text="自动方式"
                    p6s_gridLayout.children[5].text="手动方式"
                    p6s_gridLayout.children[6].text="正常模式"
                    p6s_gridLayout.children[7].text="恒控制角模式"
                    p6s_gridLayout.children[8].text="灭磁开关分"
                    p6s_gridLayout.children[9].text="灭磁开关合"
                    p6s_gridLayout.children[10].text="逆变"
                    p6s_gridLayout.children[11].text="并网运行"
                    p6s_gridLayout.children[12].text="Ug>=10%"
                    p6s_gridLayout.children[13].text="Ug>=40%"
                    p6s_gridLayout.children[14].text="励磁回空到位"
                    p6s_gridLayout.children[15].text="系统电压跟踪"
                    p6s_gridLayout.children[16].text="恒Q控制"
                    p6s_gridLayout.children[17].text="恒PF控制"
                    p6s_gridLayout.children[18].text="短路干燥模式"
                    p6s_gridLayout.children[19].text="PSS有输出"
                    p6s_gridLayout.children[20].text="PSS投入"
                    p6s_gridLayout.children[21].text="PSS闭锁"
                }
            }
        }
        Item {
            id: thirdPage
            Page_06IOMonitor_SingleChannle {
                id: page_5LimiterStatu_S
                width: swipeView_this.width
                height: swipeView_this.height
//                titleText:qsTr("系统开关量")
                anchors.left: parent.left
                anchors.leftMargin: 50*main_screen.minSize
                p6s_gridLayout.rows: 8
                p6s_gridLayout.columns: 2
                checkBoxNum: 16
                Component.onCompleted: {
                    p6s_gridLayout.children[0].text="1#功率柜退出"
                    p6s_gridLayout.children[1].text="1#功率柜均流投入"
                    p6s_gridLayout.children[2].text="1#功率柜A风机开"
                    p6s_gridLayout.children[3].text="1#功率柜B风机开"
                    p6s_gridLayout.children[4].text="2#功率柜退出"
                    p6s_gridLayout.children[5].text="2#功率柜均流投入"
                    p6s_gridLayout.children[6].text="2#功率柜A风机开"
                    p6s_gridLayout.children[7].text="2#功率柜B风机开"
                    p6s_gridLayout.children[8].text="3#功率柜退出"
                    p6s_gridLayout.children[9].text="3#功率柜均流投入"
                    p6s_gridLayout.children[10].text="3#功率柜A风机开"
                    p6s_gridLayout.children[11].text="3#功率柜B风机开"
                    p6s_gridLayout.children[12].text="4#功率柜退出"
                    p6s_gridLayout.children[13].text="4#功率柜均流投入"
                    p6s_gridLayout.children[14].text="4#功率柜A风机开"
                    p6s_gridLayout.children[15].text="4#功率柜B风机开"
                }
            }
        }

        onCurrentIndexChanged: {
            switch(swipeView_this.currentIndex)
            {
            case 0:
                button.checked = true
                button2.checked = false
                button3.checked = false
                break;
            case 1:
                button.checked = false
                button2.checked = true
                button3.checked = false
                break;
            case 2:
                button.checked = false
                button2.checked = false
                button3.checked = true
                break;
            }
        }
    }

    EXC_Normal_BtnSytle {
        id: button
        nameText: qsTr("A通道开关量")
        width: parent.width*0.22
        height: parent.height*0.09
        checked: true
        anchors.left: parent.left
        anchors.leftMargin: parent.width*0.05
        anchors.topMargin: parent.height*0.04
        anchors.top: swipeView_this.bottom
        onClicked: {
            if(swipeView_this.currentIndex==0)
                checked = true;
            else
                swipeView_this.currentIndex = 0
        }
    }

    EXC_Normal_BtnSytle {
        id: button2
        nameText: qsTr("B通道开关量")
        width: parent.width*0.22
        height: parent.height*0.09
        anchors.left: parent.left
        anchors.leftMargin: parent.width*0.30
        anchors.topMargin: parent.height*0.04
        anchors.top: swipeView_this.bottom
        onClicked: {
            if(swipeView_this.currentIndex==1)
                checked = true;
            else
                swipeView_this.currentIndex = 1
        }
    }

    EXC_Normal_BtnSytle {
        id: button3
        nameText: qsTr("系统开关量")
        width: parent.width*0.22
        height: parent.height*0.09
        anchors.left: parent.left
        anchors.leftMargin: parent.width*0.55
        anchors.topMargin: parent.height*0.04
        anchors.top: swipeView_this.bottom
        onClicked: {
            if(swipeView_this.currentIndex==2)
                checked = true;
            else
                swipeView_this.currentIndex = 2
        }
    }

    EXC_Normal_BtnUncheckStyle {
        id: button4
        nameText: qsTr("模拟量")
        width: parent.width*0.15
        height: parent.height*0.09
        anchors.left: parent.left
        anchors.leftMargin: parent.width*0.81
        anchors.topMargin: parent.height*0.04
        anchors.top: swipeView_this.bottom
        onClicked: {
            qmlSN_switchAnalog()
        }
    }
}

/*##^##
Designer {
    D{i:0;formeditorZoom:1.25}
}
##^##*/
